﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using AgentTest;
using GeneralDFS.Common.Network;
using GeneralDFS.Interface.Agent;
using NIF.MobileActors.Core;
using NIF.MobileActors.Hosts;
using GeneralDFS.DataEntity.Config;
using GeneralDFS.Client;

namespace DXWinFormDataAnalysis
{
    public class SearchNode
    {
          
        public SearchNode()
        {
            RemotingHost.RegisterLocal(IPHelper.GetLocalIP("network"),8820);
            ActorProxy<IHello> localActor = RemotingHost.LocalFacade.CreateLocalActor<IHello>(typeof(HelloAgent));
            HelloAgent act =  localActor.GetActor() as HelloAgent;
            Client client = new Client();
            Queue<IPEndPoint> hosts=new Queue<IPEndPoint>();
            foreach (NameNodeConfig nameNodeConfig in client.GetConfig().NameNodeConfigs)
            {
                var endPoint = new IPEndPoint(IPAddress.Parse(nameNodeConfig.Ip), nameNodeConfig.AgentRpcPort);
                hosts.Enqueue(endPoint);
            }
            act.Hosts = hosts;
            act.LocalHost = new IPEndPoint(IPAddress.Parse(IPHelper.GetLocalIP("network")), 8820);
            localActor.Post(h => h.Excute());
        }
     
    }
}
